<template>
  <div class="dashboard-editor-container">
    <!-- <panel-group @handleSetLineChartData="handleSetLineChartData" />

    <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
      <line-chart :chart-data="lineChartData" />
    </el-row> -->
    <button @click="ceshi">新增测试数据</button>

    <button @click="updata1">更新测试数据</button>

    <button @click="query1">查询测试数据</button>

    <button @click="queryWhere1">按条件查询测试数据</button>

    <button @click="delete1">删除测试数据</button>


  </div>
</template>

<script>
import PanelGroup from './dashboard/PanelGroup'
import LineChart from './dashboard/LineChart'
import {
  getModelWhere,
  getModelPagination,
  postModel,
  putModelById,
  deleteModelById,
  deleteModelByIds
} from '@/api/task'


const logger  = require('@/utils/electron/index').Logger('Index')
const lineChartData = {
  newVisitis: {
    expectedData: [100, 120, 161, 134, 105, 160, 165],
    actualData: [120, 82, 91, 154, 162, 140, 145]
  },
  messages: {
    expectedData: [200, 192, 120, 144, 160, 130, 140],
    actualData: [180, 160, 151, 106, 145, 150, 130]
  },
  purchases: {
    expectedData: [80, 100, 121, 104, 105, 90, 100],
    actualData: [120, 90, 100, 138, 142, 130, 130]
  },
  shoppings: {
    expectedData: [130, 140, 141, 142, 145, 150, 160],
    actualData: [120, 82, 91, 154, 162, 140, 130]
  }
}

export default {
  name: 'Index',
  components: {
    PanelGroup,
    LineChart
  },
  data() {
    return {
      lineChartData: lineChartData.newVisitis,
      task:{
        name:"1231",
        sex:"1",
      }
    }
  },
  created() {
    logger.info('环境打印示例 process.env.NODE_ENV',process.env.NODE_ENV);

  },
  methods: {
    ceshi(){
      logger.info('添加测试数据1');
      postModel(this.task).then(result => {
        if (result.code === 200) {
          //  this.setSnackSuccessMsg()
          logger.info('成功');
        } else {
          logger.info('失败');
          //   this.setSnackFailedMsg()
        }

      }).catch(err => {
        logger.info('失败');
        logger.info(err);
         //this.setSnackFailedMsg(err.message)
        // 显示结果
      })
    },
    updata1(){
      putModelById(1, this.task).then(result => {
        if (result.code === 200) {
          logger.info('成功');
        } else {
          logger.info('失败');
        }

      }).catch(err => {
        logger.info('失败');
        logger.info(err);
      })

    },




    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type]
    },

    setSnackFailedMsg(msg) {
      this.submitResult = false
      this.snackbarMsg = msg ? msg : DEFAULT_FAILED_MSG
    },
    setSnackSuccessMsg(msg) {
      this.submitResult = true
      this.snackbarMsg = msg ? msg : DEFAULT_SUCCESS_MSG
    },
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

@media (max-width:1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
</style>
